import { LoginResponse } from '@/services/login/typings';
import { DataResponse } from '@/services/typing';
import { toUrlParams } from '@/utils/toUrlParams';
import { request } from '@umijs/max';
import { UserLoginParams } from './typings';

export function getCaptcha() {
  return request('/common/captcha', {
    method: 'GET',
  });
}

export function login(
  data: UserLoginParams,
): Promise<DataResponse<LoginResponse>> {
  const formData = toUrlParams(data);
  return request('/common/login', {
    method: 'POST',
    data: formData,
  });
}
